#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <aclconio.h>
#include <define.h>
#include <transact.h>
#include <tran.h>
#include <gds.h>
#include <sizes.h>
#include "ConfProto.h"
#include "tblutil.h"
#include <\SOFTPAY\Ver30\source\include\sizes.h>
#include <\SOFTPAY\Ver30\HostSrc\citisrc\citiids.h>
#include <\SOFTPAY\Ver30\HostSrc\cpacsrc\cpacids.h>
#include <confio.h>

#include <\SOFTPAY\Ver30\source\include\MNU.h>



static void *storeFromStruct;

static int recordNum;
void registerMNU(void *ptr)
{
	 storeFromStruct = ptr;
}

void *dealWithAddressBoundary(void*address);
int	inLoadMNURecFromStruct (int inRecNumber, void *vdStruct)
{
	int inRet;
	char* tmp = (char*)vdStruct;

	registerMNU(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inLoadConfRec(MNU_FILENAME, SIZE_MNU_REC, inRecNumber, vdStruct);

	recordNum = inRecNumber;
	return inRet;
}

void vdRestoreMNURecFromStruct(void *vdStruct)
{
	registerMNU(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	memcpy((char *) pvdGetMNURec(), vdStruct, SIZE_MNU_REC);

}

void vdCopyMNURecFromStruct(void *vdStruct)
{
	registerMNU(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
		memcpy(vdStruct, (char *) pvdGetMNURec(), SIZE_MNU_REC);

}

int	inSaveMNURecFromStruct (int inRecNumber,  void *vdStruct)
{
	int inRet;

	registerMNU(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(MNU_FILENAME, SIZE_MNU_REC, inRecNumber, (char *) vdStruct);

	return inRet;
}

int	inUpdateMNURecFromStruct (void *vdStruct)
{
	int inRet;

	registerMNU(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(MNU_FILENAME, SIZE_MNU_REC, recordNum, (char *) vdStruct);

	return inRet;
}

short inGetMNUMenuIndexFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetMNUMenuIndex();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MNU_REC*)vdStruct)->inMNUMenuIndex;
}

void vdSetMNUMenuIndexFromStruct(short inMNUMenuIndex, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMNUMenuIndex(inMNUMenuIndex);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MNU_REC*)vdStruct)->inMNUMenuIndex = inMNUMenuIndex;
}

char* szGetMNUMenuNameFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetMNUMenuName();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MNU_REC*)vdStruct)->szMNUMenuName;
}

void vdSetMNUMenuNameFromStruct(const char* szMNUMenuName, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMNUMenuName(szMNUMenuName);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((MNU_REC*)vdStruct)->szMNUMenuName, szMNUMenuName, sizeof(((MNU_REC*)NULL)->szMNUMenuName)-1);
}

short inGetMNUActionCodeFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetMNUActionCode();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MNU_REC*)vdStruct)->inMNUActionCode;
}

void vdSetMNUActionCodeFromStruct(short inMNUActionCode, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMNUActionCode(inMNUActionCode);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MNU_REC*)vdStruct)->inMNUActionCode = inMNUActionCode;
}

short inGetMNUBitmapIDFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetMNUBitmapID();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MNU_REC*)vdStruct)->inMNUBitmapID;
}

void vdSetMNUBitmapIDFromStruct(short inMNUBitmapID, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMNUBitmapID(inMNUBitmapID);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MNU_REC*)vdStruct)->inMNUBitmapID = inMNUBitmapID;
}

short inGetMNUFooterIDFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetMNUFooterID();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MNU_REC*)vdStruct)->inMNUFooterID;
}

void vdSetMNUFooterIDFromStruct(short inMNUFooterID, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMNUFooterID(inMNUFooterID);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MNU_REC*)vdStruct)->inMNUFooterID = inMNUFooterID;
}

short inGetMNUDataIDFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetMNUDataID();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MNU_REC*)vdStruct)->inMNUDataID;
}

void vdSetMNUDataIDFromStruct(short inMNUDataID, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMNUDataID(inMNUDataID);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MNU_REC*)vdStruct)->inMNUDataID = inMNUDataID;
}

short inGetMNUPasswordLevelFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetMNUPasswordLevel();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((MNU_REC*)vdStruct)->inMNUPasswordLevel;
}

void vdSetMNUPasswordLevelFromStruct(short inMNUPasswordLevel, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetMNUPasswordLevel(inMNUPasswordLevel);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((MNU_REC*)vdStruct)->inMNUPasswordLevel = inMNUPasswordLevel;
}

